package eu.flexblog.core {
 /**
 * Flex Blog application facade 
 * 
 * @author  Mike Bevz <myb@mikebevz.com>
 * @version $Id$
 * 
 */

	import eu.flexblog.core.controller.StartupCmd;
	
	import org.puremvc.as3.multicore.interfaces.IFacade;
	import org.puremvc.as3.multicore.patterns.facade.Facade;
		
	public class ApplicationFacade extends Facade implements IFacade
	{
		/* Notification constants */ 
		public static const STARTUP:String 		 = 'startup';
		public static const LOAD_MODULES:String  = 'loadModules';
		public static const SHOW_APP:String 	 = 'showApp';
		public static const ADD_WIDGET:String 	 = 'addWidget';
		public static const REMOVE_WIDGET:String = 'removeWidget';
		public static const ADD_MODULE:String    = 'addModule';
		
		/**
		 * 
		 * @param key Facade key
		 * 
		 */		
		public function ApplicationFacade(key:String)
		{
			super(key);	
		}
        /**
         * Singleton ApplicationFacade Factory Method
         *  
         * @param key Facade key
         * @return ApplicationFacade
         * 
         */
        public static function getInstance(key:String):ApplicationFacade 
        {
            if ( instanceMap[key] == null ) instanceMap[key] = new ApplicationFacade(key);
            return instanceMap[key] as ApplicationFacade;
        }
        
        /**
         * Register Commands with the Controller  
         * 
         */        
        override protected function initializeController() : void 
        {
            super.initializeController();            
            registerCommand(STARTUP, StartupCmd);
        }
		
		/**
         * Application startup
         * 
         * @param app a reference to the application component 
         */  
        public function startup(app:flexblog):void
        {
        	sendNotification(STARTUP, app);
        }
	}
	
} 